package com.szm.business.action;

import com.szm.business.util.ActionConstant;
import com.szm.business.util.SysConstant;
import com.szm.business.vo.UserVo;
import com.szm.mvc.action.base.ActionSupport;

/**
 * @author szm
 * @ClassName UserAction.java
 * @Description 用户Action
 *				自动注入属性,JavaBean
 */
public class UserAction extends ActionSupport{

	/**
	 * userVo 用户.
	 */
	private UserVo userVo;
	
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		return ActionConstant.LOGIN;
	}

	/**
	 * @author szm
	 * @Description 添加用户
	 * @return
	 */
	public String add(){
		if(null == userVo){
			System.out.println(SysConstant.SYS_FAIL+"添加用户失败!");
			return ActionConstant.ADD;
		}
		System.out.println(SysConstant.SYS_INFO+"添加用户成功:"+userVo.toString());
		return ActionConstant.USERLIST;
	}
	
	/**
	 * @author szm
	 * @Description 编辑用户
	 * @return
	 */
	public String edit(){
		if(null == userVo){
			System.out.println(SysConstant.SYS_FAIL+"编辑用户失败！");
			return ActionConstant.EDIT;
		}
		System.out.println(SysConstant.SYS_INFO+"编辑用户成功:"+userVo.toString());
		return ActionConstant.USERLIST;
	}
	
	/**
	 * @author szm
	 * @Description 删除用户
	 * @return
	 */
	public String delete(){
		System.out.println(SysConstant.SYS_INFO+"删除用户");
		return ActionConstant.DELETE;
	}
	
	/**
	 * @author szm
	 * @Description 用户列表
	 * @return
	 */
	public String list(){
		System.out.println(SysConstant.SYS_INFO+"跳转用户列表");
		return ActionConstant.USERLIST;
	}
	
	/**
	 * @Author szm
	 * @Description ajax请求 返回json
	 * @return
	 */
	public String ajaxUpdate(){
		if(null == userVo){
			System.out.println(SysConstant.SYS_FAIL+"ajax更新用户失败！");
			return ActionConstant.AJAXUPDATE;
		}
		dataMap.clear();
		dataMap.put("SUCCESS", "操作成功！");
		dataMap.put("userVo", userVo);
		return ActionConstant.DATAMAP;
	}
	
	public UserVo getUserVo() {
		return userVo;
	}

	public void setUserVo(UserVo userVo) {
		this.userVo = userVo;
	}
	
	
}
